namespace FIREFLYX {
    /** 后渲染 一张纹理 着色器 */
    export const BUILTIN_SHADER_POSTEFF_IMAGE = `postEffImage`;
    DefaultAsset.shaderGenMap[BUILTIN_SHADER_POSTEFF_IMAGE] = () => {
        const vsCode = `#version 300 es
            precision highp float;
            precision highp int;
            layout (location = 0) in vec4 a_Position; //顶点 位置 是有默认值的 (0,0,0,1)
            layout (location = 3) in vec2 a_UV;       //UV 纹理坐标
            out vec2 v_uv;
            void main() {
                v_uv = a_UV;
                vec4 pos = vec4(a_Position.xyz , 1.0);
                gl_Position = pos;
            }
        `;

        const fsCode = `#version 300 es
            precision highp float;
            precision highp int;
            uniform sampler2D u_mainTex;
            in vec2 v_uv;
            out vec4 color;
            void main(){
                vec4 texColor = texture(u_mainTex , v_uv);    //纹理
                color = texColor;
            }
        `;
        //glsl
        const vs = new GLSL();
        vs.setCode(vsCode);
        const fs = new GLSL();
        fs.setCode(fsCode);

        //shader
        let result: Shader = new Shader();
        result.tag = BUILTIN_SHADER_POSTEFF_IMAGE;
        result.lightMode = RenderPipeline.LM_FORWARD;
        result.vertexGLSL = vs;
        result.fragmentGLSL = fs;
        //unifrom 默认值
        result.definePropertyMap = {};

        result.definePropertyMap.u_mainTex = {
            type:"texture",
            value: "White"
        };

        //apply
        result.apply();

        return result;
    };
}